|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
T - The type of a state object that the transaction handler can use to
pass information from the beforeCommit(TransactionData)
event dispatch method to the
afterCommit(TransactionData, Object) or
afterRollback(TransactionData, Object) method, depending
on whether the transaction succeeded or failed.public interface TransactionEventHandler<T>
The interface of an event handler for Neo4j Transaction events.
Once it has been registered at a GraphDatabaseService instance
it will receive events about what has happened in each transaction which is
about to be committed. Handlers won't get notified about transactions which
hasn't performed any write operation or won't be committed (either if
Transaction.success() hasn't been called or the transaction has been
marked as failed, Transaction.failure().
Right before a transaction is about to be committed
the beforeCommit(TransactionData) method is called with the entire
diff of modifications made in the transaction. At this point the transaction
is still running so changes can still be made. However there's no guarantee
that other handlers will see such changes since the order in which handlers
are executed is undefined. This method can also throw an exception and will,
in such a case, prevent the transaction from being committed.
If beforeCommit(TransactionData) is successfully executed the
transaction will be committed and the
afterCommit(TransactionData, Object) method will be called with
the same transaction data as well as the object returned from
beforeCommit(TransactionData). This assumes that all other handlers
(if more were registered) also executed
beforeCommit(TransactionData) successfully).
If beforeCommit(TransactionData) isn't executed successfully,
but instead throws an exception the transaction won't be committed and a
TransactionFailureException will (eventually) be thrown from
Transaction.finish(). All handlers which at this point have had its
beforeCommit(TransactionData) method executed successfully will
receive a call to afterRollback(TransactionData, Object).
| Method Summary | |
|---|---|
void |
afterCommit(TransactionData data,
T state)
Invoked after the transaction has been committed successfully. |
void |
afterRollback(TransactionData data,
T state)
Invoked after the transaction has been rolled back if committing the transaction failed for some reason. |
T |
beforeCommit(TransactionData data)
Invoked when a transaction is about to be committed. |
| Method Detail |
|---|
T beforeCommit(TransactionData data)
throws Exception
TransactionFailureException will be thrown from
Transaction.finish().
The transaction is still open when this method is invoked, making it
possible to perform mutating operations in this method. This is however
highly discouraged. Changes made in this method are not guaranteed to be
visible by this or other TransactionEventHandlers.
data - the changes that will be committed in this transaction.
null) that will be passed on to
afterCommit(TransactionData, Object) or
afterRollback(TransactionData, Object) of this object.
Exception - to indicate that the transaction should be rolled back.
void afterCommit(TransactionData data,
T state)
data - the changes that were committed in this transaction.state - the object returned by
beforeCommit(TransactionData).
void afterRollback(TransactionData data,
T state)
data - the changes that were committed in this transaction.state - the object returned by
beforeCommit(TransactionData).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||